<?php
$this->display('public/header.phtml', array(
    "title" => (empty($admin) ? "增加" : "编辑") . "内容",
    "styles" => '',
    "crumbArr" => array(
        array("href" => "/admin/content/index/", "title" => "内容列表"),
        array("title" => (empty($admin) ? "增加" : "编辑") . "内容"),
    ),
));
?>

<?php // 在线编辑器相关 ?>
    <script type="text/javascript" charset="utf-8" src="/admin_resources/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/admin_resources/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/admin_resources/ueditor/lang/zh-cn/zh-cn.js"></script>
<?php // 上传空间 ?>
    <link rel="stylesheet" type="text/css" href="/admin_resources/our/swfupload/upload.css"/>
    <script src="/admin_resources/our/upload_iframe.js"></script>
    <!--BEGIN CONTENT-->
    <div class="row">
        <div class="col-xs-12">
            <!-- PAGE CONTENT BEGINS -->
            <form id="content" class="form-horizontal" method="post" role="form">

                <div id="content_title" class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label no-padding-right"> 标 题 </label>
                    <div class="col-xs-12 col-sm-5">
                    <span class="block input-icon input-icon-right">
                        <input name="content_title" type="text" value="" class="width-60"/>
                    </span>
                    </div>
                </div>

                <div id="category_id" class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label no-padding-right"> 所属分类 </label>
                    <div class="col-xs-12 col-sm-5">
                    <span class="block input-icon input-icon-right">
                        <select name="category_id" class="col-xs-10 col-sm-5">
                            <?php foreach ($categoryList as $value): ?>
                                <option value="<?php echo $value['category_id']; ?>"><?php echo $value['category_name']; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </span>
                    </div>
                </div>

                <div id="content" class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label no-padding-right"> 内 容 </label>
                    <div class="col-xs-12 col-sm-10">
                    <span class="block input-icon input-icon-right">
                       <script id="editor" name="content" type="text/plain" style="height: 300px;""></script>
                        <!--<textarea name="content" class="width-90" rows="10"></textarea>-->

                    </span>
                    </div>
                </div>

                <div id="content_image" class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label no-padding-right"> 图 片 </label>
                    <div class="col-xs-12 col-sm-5">
                    <span class="block input-icon input-icon-right">
                        <input type="hidden" name="content_image" value="" class="width-50 upload_image image_preview"
                               image_preview_width="200"/>
                    </span>
                    </div>
                </div>

                <div id="status" class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label no-padding-right"> 状 态 </label>
                    <div class="col-xs-12 col-sm-5">
                    <span class="block input-icon input-icon-right">
                        <select name="status" class="col-xs-10 col-sm-5">
                            <?php foreach ($statusConfig as $key => $value): ?>
                                <option value="<?php echo $key; ?>"><?php echo $value['name']; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </span>
                    </div>
                </div>

                <div id="add_time" class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label no-padding-right"> 增加时间 </label>
                    <div class="col-xs-12 col-sm-5">
                    <span class="block input-icon input-icon-right">
                        <input name="add_time" type="text" value="" class="width-60"/>
                    </span>
                    </div>
                </div>

                <div id="source" class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label no-padding-right"> 来 源 </label>
                    <div class="col-xs-12 col-sm-5">
                    <span class="block input-icon input-icon-right">
                        <input name="source" type="text" value="" class="width-60"/>
                    </span>
                    </div>
                </div>

                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            提 交
                        </button>
                    </div>
                </div>

                <?php $this->display("public/form.phtml"); ?>
            </form>

        </div><!-- /.col -->
    </div><!-- /.row -->

<?php
$this->display("public/footer.phtml", array(
    "scripts" => ''
));
?>
    <script type="text/javascript">
        var ue = UE.getEditor('editor');
        $(document).ready(function () {
            $("#content").submit(function () {
                // 移除内容样式
                UE.getEditor('editor').execCommand("removeformat");

                var content = UE.getEditor('editor').getContent();
                UE.getEditor('editor').setContent(content);
                return true;
            });
        });
    </script>
<?php $this->display("public/edit_footer.phtml"); ?>
<?php $this->display("public/footer_body.phtml"); ?>